#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
stack<int> s;
vector<int> v;
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if (x != 0)
		{
			if (s.size() < 10)
				s.push(x);
			else
				cout << "FULL"<<" ";
		}
		else
		{
			if (!s.empty())
			{
				cout << s.top()<<" ";
				s.pop();
			}
			else
				cout << "EMPTY"<<" ";
		}
	}
	cout << endl;
	while (!s.empty())
	{
		//cout << s.top() << " ";
		v.push_back(s.top());
		s.pop();
	}
	for (int i = v.size() - 1; i >= 0; i--)
		cout << v[i] << " ";
	return 0;
}